package dicebot.apps;

import dicebot.abstracts.MessageHandler;
import dicebot.filene.Main;
import dicebot.tools.dice.DiceTool;
import net.mamoe.mirai.event.events.GroupMessageEvent;

public class Roll {
	
	public static void initialize () {
		Main.HANDLERS.add(new MessageHandler() {
			@Override
			public boolean handle(GroupMessageEvent e) {
				String[] sub = e.getMessage().contentToString().split(" ");
				if (sub.length > 0 && sub[0].equals(".r")) {					
					String result = DiceTool.handle(sub, e.getSenderName());
					e.getGroup().sendMessage(result);
					return true;
				} else {
					return false;
				}
			}
		});
	}
	
}
